--愁伺爆破
local chousibaopo = fk.CreateSkill {
    name = "mcdh_chousibaopo",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

chousibaopo:addEffect(fk.Damaged,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target == player
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askForSkillInvoke(target, self.name, data)
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(1,self.name)
        if data.from and not (data.from:isNude() or player:isNude())  then
            local  targets =room:getAlivePlayers(true)
            targets = table.filter(targets,function(p) return p == player or p == data.from  end)
            local  ret =room:askToJointCards(player,{
                players = targets,
                skill_name = self.name,
                cancelable = false,
                pattern = '.',
                max_num = 1 ,
                min_num = 1 ,
                include_equip = true,
                prompt = "#chousibaopo-card"
            })


            for _, p in ipairs(targets) do
                if not p.dead then
                    p:showCards( ret[p])
                end
            end
            if Fk:getCardById( ret[player][1]).color == Fk:getCardById(ret[data.from][1]).color then
                local id =room:askForCardChosen(player, data.from, "h", self.name, "#chousibaopo:"..data.from.id)
                room:throwCard(id,self.name,data.from,player)
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_chousibaopo"] = "愁伺爆破",
    [":mcdh_chousibaopo"] = "当你受到伤害后，你可以摸一张然后与伤害来源同时展示一张牌：若颜色相同，你弃置其一张手牌。",
    ["#chousibaopo"] = "愁伺爆破:弃置 %src 一张牌",
    ["#chousibaopo-card"] = "愁伺爆破:展示一张牌"
}

return chousibaopo